@echo off

set dir=E:\ACM\CodeTesting\C_\debug-test
set compile_test=g++ -std=c++20 test.cpp -o test.exe
set compile_std=g++ -std=c++20 std.cpp -o std.exe
set compile_rnd=g++ -std=c++20 rnd.cpp -o rnd.exe

E:
cd %dir%

for %%i in ("%1", "%2", "%3") do (
    if %%i == "test" (
        echo %compile_test%
        %compile_test%
    )
    if %%i == "std" (
        echo %compile_std%
        %compile_std%
    )
    if %%i == "rnd" (
        echo %compile_rnd%
        %compile_rnd%
    )
)

for /L %%i in (1, 1, 100) DO (
    start /B /WAIT rnd.exe > "data_rnd.txt"
    start /B /WAIT test.exe > "data_test.txt" < "data_rnd.txt"
    start /B /WAIT std.exe > "data_std.txt" < "data_rnd.txt"
    rem for /f "delims=" %%a in (data_test.txt) do echo.%%a
    rem for /f "delims=" %%a in (data_std.txt) do echo.%%a
    fc "data_test.txt" "data_std.txt"
    if errorlevel 1 goto end
    echo "------------------------------------------------------"
)

:end

